import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

//Java 标准库线程池的创建方式总共有几种？分别使用代码创建并演示一下
public class Homework3 {
    public static void main(String[] args) {
        //固定线程数的线程池
        Executors.newFixedThreadPool(4);
        //创建一个只包含单个线程的线程池
        Executors.newSingleThreadExecutor();
        //创建一个固定线程个数,但是任务延时执行的线程池
        Executors.newScheduledThreadPool(4);
        //创建一个最普通的线程池
        ExecutorService service = Executors.newCachedThreadPool();
        for (int i = 0; i <100 ; i++) {
            int id = i;
            service.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println("count = "+id);
                }
            });
        }
    }
}
